To draw a Bezier curve in a picture environment, we propose a PostScript implementation
with curveto
operator. For this purpose, we need 4 points
(x0, y0),(x1, y1),(x2, y2),(x3, y3) which define the tangents of the curve of
figure .
Then, a polynomial interpolation is utilized to draw the ``best'' curve between
points
(x0, y0),(x3, y3). The macro is called Bezierps
and admits as
parameters a list of points. For TEX, this list ends when the syntatic
analysor encounters the key word \endbezierps
which constitutes the
first parameter of the macro (for explanations about macros with mark out
arguments see [2] page 201).
The body of the macro is built with a PostScript abstraction on lists – the
forall
operator– corresponding to the Lisp function map
.
In our case, we apply curveto
to a finite list of 4 points. This
allows the use of only one curveto
order. This construction is more
efficient than a construction with curveto
operators for each curve.
The gain in disk space is obvious in the case of multiple curves in the
application.
The drawing of figure has been realized under TEXcad on a PC
machine. This software from the EMTEX package doesn't allow for the drawing of
Bezier curves ; it constrains us to mark explicitly the points
(x0, y0) ... (x3, y3), then edit the file and insert coordinantes
as parameters of the macro Bezierps
. We code:
\begin{figure}[th] \begin{center} \unitlength=1.00mm \linethickness{0.4pt} \begin{picture}(60,50) \put(0.00,0.00){\framebox(60,50)[t]{}} % debut de la courbe de bezier \put(0,0){\bezierps [ [ 10 10 15 25 45 45 50 25 ] ] \endbezierps{.4}{3}{2}{255}{0}{0}} \put(10,5){\makebox(0,0)[cc]{$(x_0,y_0)$}} \put(7,25){\makebox(0,0)[cc]{$(x_1,y_1)$}} \put(36,45){\makebox(0,0)[cc]{$(x_2,y_2)$}} \put(50,22){\makebox(0,0)[cc]{$(x_3,y_3)$}} \put(10,10){\makebox(0,0)[cc]{$\bullet$}} \put(15,25){\makebox(0,0)[cc]{$\bullet$}} \put(45,45){\makebox(0,0)[cc]{$\bullet$}} \put(50,25){\makebox(0,0)[cc]{$\bullet$}} \put(10,10){\line(1,3){5}} \put(45,45){\line(1,4){5}} \end{picture} \caption{{\it B\'ezier curve}} \label{figone} \end{center} \end{figure}